// Copyright 2011 Jefferson Willian
// willmont7@gmail.com

#include <cstdio>

#define MAX 10001

int main() {
  int p;
  int s;
  int in[2];
  bool beach[MAX];   // Posicoes da praia
  int games = 1;
  int j;

  while (scanf("%d%d", &p, &s) && p != 0 || s != 0) {
    /* Seta posicoes como falsas */
    for (int i = 0;i <= p;i++)
      beach[i] = false;

    /* Marca novas posicoes */
    for (int i = 0;i < s;i++) {
      scanf("%d%d", &in[0], &in[1]);
      for (j = in[0];j < in[1];j++)
        beach[j] = true;
    }

    printf("Teste %d\n", games++);

    /* Verifica os limites marcados */
    for (int i = 0;i <= p;i++)
      if (beach[i]) {
        j = i+1;
        while (beach[j]) j++;
        printf("%d %d\n", i, j);
        i = j-1;
      }

    printf("\n");
  }
}
